package com.srwl.mytx.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.srwl.mytx.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by dahai2070 on 2016/10/6 0006.
 */
public class GoodsClassfyAdapter extends RecyclerView.Adapter<GoodsClassfyAdapter.GoodsClassfyHolder> {
    private static final int GOODS_STATUS_AUCTION = 1;
    private static final int GOODS_STATUS_NOT_AUCTION = 0;
    public static final int ITEM_TYPE_HEADER = 2;
    private List<String> classfyDateList;
    private Context mContext;
    private LayoutInflater inflater;
    private int mHeaderCount = 1;

    public GoodsClassfyAdapter(List<String> classfyDateList, Context mContext) {
        this.classfyDateList = classfyDateList;
        this.inflater = LayoutInflater.from(mContext);
        this.mContext = mContext;
    }

    public interface OnItemClickListener {
        void classfyType(String classfy);
    }

    private OnItemClickListener onItemClickListener;

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }


    @Override
    public GoodsClassfyHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = inflater.inflate(R.layout.goods_classfy_item_layout, parent, false);
        return new GoodsClassfyHolder(view);

    }

    @Override
    public void onBindViewHolder(GoodsClassfyHolder holder, int position) {
        final String content = classfyDateList.get(position);
        holder.tv_classfyItem.setText(content);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
          onItemClickListener.classfyType(content);
            }
        });
    }


    @Override
    public int getItemCount() {
        return classfyDateList.size();
    }


    class GoodsClassfyHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_classfy_item)
        TextView tv_classfyItem;

        public GoodsClassfyHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }

}